home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.3 (Developer)…68k, x86, SPARC, PA-RISC] / NeXTSTEP 3.3 Dev Intel.iso / NextDeveloper / Headers / kernserv / printf.h < prev    next >
Text File  |  1995-02-14  |  4KB  |  127 lines

  1. /*    @(#)printf.h    1.0    2/2/90        (c) 1990 NeXT    */
  2.  
  3. /* 
  4.  * HISTORY
  5.  *  2-Feb-90  Gregg Kellogg (gk) at NeXT
  6.  *    Created.
  7.  *
  8.  */ 
  9.  
  10. #ifndef _KERN_INTERNAL_PRINTF_
  11. #define _KERN_INTERNAL_PRINTF_
  12.  
  13. #if KERNEL
  14. #import <sys/types.h>
  15. #import <sys/buf.h>
  16. #import <sys/tty.h>
  17. #import <ansi/stdarg.h>
  18.  
  19. #if    NeXT
  20. /*
  21.  * bit field descriptions for printf %r and %R formats
  22.  */
  23.  
  24. /*
  25.  * printf("%r %R", val, reg_descp);
  26.  * struct reg_desc *reg_descp;
  27.  *
  28.  * the %r and %R formats allow formatted output of bit fields.
  29.  * reg_descp points to an array of reg_desc structures, each element of the
  30.  * array describes a range of bits within val.  the array should have a
  31.  * final element with all structure elements 0.
  32.  * %r outputs a string of the format "<bit field descriptions>"
  33.  * %R outputs a string of the format "0x%x<bit field descriptions>"
  34.  *
  35.  * The fields in a reg_desc are:
  36.  *    unsigned rd_mask;    An appropriate mask to isolate the bit field
  37.  *                within a word, and'ed with val
  38.  *
  39.  *    int rd_shift;        A shift amount to be done to the isolated
  40.  *                bit field.  done before printing the isolate
  41.  *                bit field with rd_format and before searching
  42.  *                for symbolic value names in rd_values
  43.  *
  44.  *    char *rd_name;        If non-null, a bit field name to label any
  45.  *                out from rd_format or searching rd_values.
  46.  *                if neither rd_format or rd_values is non-null
  47.  *                rd_name is printed only if the isolated
  48.  *                bit field is non-null.
  49.  *
  50.  *    char *rd_format;    If non-null, the shifted bit field value
  51.  *                is printed using this format.
  52.  *
  53.  *    struct reg_values *rd_values;    If non-null, a pointer to a table
  54.  *                matching numeric values with symbolic names.
  55.  *                rd_values are searched and the symbolic
  56.  *                value is printed if a match is found, if no
  57.  *                match is found "???" is printed.
  58.  *
  59.  * printf("%n %N", val, reg_valuesp);
  60.  * struct reg_values *reg_valuesp;
  61.  *
  62.  * the %n and %N formats allow formatted output of symbolic constants
  63.  * Reg_valuesp is a pointer to an array of struct reg_values which pairs
  64.  * numeric values (rv_value) with symbolic names (rv_name).  The array is
  65.  * terminated with a reg_values entry that has a null pointer for the
  66.  * rv_name field.  When %n or %N is used rd_values are searched and the
  67.  * symbolic value is printed if a match is found, if no match is found
  68.  * "???" is printed.
  69.  *                
  70.  * printf("%C", val);
  71.  * int val;
  72.  *
  73.  * the %C format prints an int as a 4 character string.
  74.  * The most significant byte of the int is printed first, the least
  75.  * significant byte is printed last.
  76.  */
  77.  
  78. /*
  79.  * register values
  80.  * map between numeric values and symbolic values
  81.  */
  82. struct reg_values {
  83.     unsigned rv_value;
  84.     char *rv_name;
  85. };
  86.  
  87. /*
  88.  * register descriptors are used for formatted prints of register values
  89.  * rd_mask and rd_shift must be defined, other entries may be null
  90.  */
  91. struct reg_desc {
  92.     unsigned rd_mask;    /* mask to extract field */
  93.     int rd_shift;        /* shift for extracted value, - >>, + << */
  94.     char *rd_name;        /* field name */
  95.     char *rd_format;    /* format to print field */
  96.     struct reg_values *rd_values;    /* symbolic names of values */
  97. };
  98.  
  99. #endif    NeXT
  100.  
  101. /*
  102.  * Flags arguments to prf()
  103.  */
  104. #define TOCONS    0x1
  105. #define TOTTY    0x2
  106. #define TOLOG    0x4
  107. #define    TOSTR    0x8
  108.  
  109. extern const char *panicstr;
  110.  
  111. int printf(const char *format, ...);
  112. int uprintf(const char *format, ...);
  113. int tprintf(struct tty *tp, const char *format, ...);
  114. int sprintf(char *s, const char *format, ...);
  115. int log(int level, const char *format, ...);
  116. int prf(const char *fmt, va_list ap, int flags, struct tty *ttyp);
  117. void panic_init(void);
  118. void panic(const char *s);
  119. void tablefull(const char *tab);
  120. void harderr(struct buf *bp, const char *cp);
  121. int (putchar)(int c);
  122. void logchar(int c);
  123.  
  124. #endif    KERNEL
  125.  
  126. #endif _KERN_INTERNAL_PRINTF_
  127.